package com.hospital.pony.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hospital.R;
import com.hospital.pony.model.UserModel;

import java.util.List;

public class DoctorAdapter extends BaseAdapter {
	private LayoutInflater inflater;
	private List<UserModel> list_result;
	private int posIndex;
	private Context mContext;

	public DoctorAdapter(Context context, List<UserModel> list_result) {
		mContext = context;
		inflater = LayoutInflater.from(context);
		this.list_result = list_result;
	}

	@Override
	public int getCount() {
		return list_result.size();
	}

	@Override
	public Object getItem(int position) {
		return list_result.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.item_docrotmessage, null);
			holder = new ViewHolder();
			holder.doctorName = (TextView) convertView.findViewById(R.id.doctorName);
			holder.doctorTime = (TextView) convertView.findViewById(R.id.doctorTime);
			holder.mivUserImage = (ImageView) convertView.findViewById(R.id.mivUserImage);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		try {
			holder.doctorName.setText(list_result.get(position).getUname());
			holder.doctorTime.setText("职称："+list_result.get(position).getULeave());


//			if (!TextUtils.isEmpty(list_result.get(position).getDoctorImage())) {
//				Picasso.with(mContext).load(Consts.URL_IMAGE_LOCAL + list_result.get(position).getDoctorImage())
//						.placeholder(R.drawable.default_drawable_show_pictrue).into(holder.mivUserImage);
//			}

		} catch (Exception e) {
			// TODO: handle exception
		}

		return convertView;

	}

	private class ViewHolder {
		private TextView doctorTime;
		private TextView doctorName;
		private ImageView mivUserImage;

	}

	public void setPos(int pos) {
		posIndex = pos;
	}

}
